package com.ruoyi.project.charging.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.charging.domain.CChargingPoint;
import com.ruoyi.project.charging.service.ICChargingPointService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 设备测点Controller
 * 
 * @author Yaoxuan Mo
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/charging/point")
public class CChargingPointController extends BaseController
{
    @Autowired
    private ICChargingPointService cChargingPointService;

    /**
     * 查询设备测点列表
     */
    @PreAuthorize("@ss.hasPermi('charging:point:list')")
    @GetMapping("/list")
    public TableDataInfo list(CChargingPoint cChargingPoint)
    {
        startPage();
        List<CChargingPoint> list = cChargingPointService.selectCChargingPointList(cChargingPoint);
        return getDataTable(list);
    }

    /**
     * 导出设备测点列表
     */
    @PreAuthorize("@ss.hasPermi('charging:point:export')")
    @Log(title = "设备测点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CChargingPoint cChargingPoint)
    {
        List<CChargingPoint> list = cChargingPointService.selectCChargingPointList(cChargingPoint);
        ExcelUtil<CChargingPoint> util = new ExcelUtil<CChargingPoint>(CChargingPoint.class);
        util.exportExcel(response, list, "设备测点数据");
    }

    /**
     * 获取设备测点详细信息
     */
    @PreAuthorize("@ss.hasPermi('charging:point:query')")
    @GetMapping(value = "/{pointId}")
    public AjaxResult getInfo(@PathVariable("pointId") Long pointId)
    {
        return success(cChargingPointService.selectCChargingPointByPointId(pointId));
    }

    /**
     * 新增设备测点
     */
    @PreAuthorize("@ss.hasPermi('charging:point:add')")
    @Log(title = "设备测点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CChargingPoint cChargingPoint)
    {
        return toAjax(cChargingPointService.insertCChargingPoint(cChargingPoint));
    }

    /**
     * 修改设备测点
     */
    @PreAuthorize("@ss.hasPermi('charging:point:edit')")
    @Log(title = "设备测点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CChargingPoint cChargingPoint)
    {
        return toAjax(cChargingPointService.updateCChargingPoint(cChargingPoint));
    }

    /**
     * 删除设备测点
     */
    @PreAuthorize("@ss.hasPermi('charging:point:remove')")
    @Log(title = "设备测点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pointIds}")
    public AjaxResult remove(@PathVariable Long[] pointIds)
    {
        return toAjax(cChargingPointService.deleteCChargingPointByPointIds(pointIds));
    }
}
